import React from 'react'

import { NavBar } from 'antd-mobile'

import { withRouter } from 'react-router-dom'

import propTypes  from 'prop-types'
// 导入样式

import styles from './index.module.css'

function NavHeader({ children, history,onLeftClick }) {
    const defaultHander = () => history.go(-1)
    return (
            <NavBar
                className={styles.navbar}
                mode="light"
                icon={<i className="iconfont icon-back" />}
                onLeftClick={onLeftClick || defaultHander}
            >
                {children}
            </NavBar>

    )
}

NavHeader.propTypes = {
    children: propTypes.string.isRequired,
    onLeftClick: propTypes.func
}
export default withRouter(NavHeader)